from coin.exchange.base.kr_rest.py_product import PyProduct
from coin.exchange.base.kr_rest.product_info import (
    ProductInfo, ProductHolder, ProductInfoConstant)
from coin.exchange.okex.kr_rest.constants import pi_file
from coin.exchange.okex.kr_rest.currency import OkexCurrency
from coin.exchange.okex_futures.kr_rest.futures_product import OkexFuturesProduct


okex_product_info = ProductInfoConstant(pi_file)


def get_holder_from_product(product):
  if isinstance(product, PyProduct):
    assert product.market_name == 'Futures' and product.exchange_name == 'Okex'
  else:
    assert isinstance(product, OkexFuturesProduct)
  product_info = okex_product_info.get_product_info(product.relative_norm)
  return ProductHolder(product, product_info)
